package PyroBots.Vue;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;

import PyroBots.Controlleur.CSimulateur;
import PyroBots.Controlleur.CTerrain;
import PyroBots.Vue.Listeners.ButtonFeuListener;
import PyroBots.Vue.Listeners.CarteMouseListener;

public class ButtonFF extends JButton{
	private boolean isActivate = false;
	private String IconActivated = null;
	private String IconDesactivated = null;

	public ButtonFF(String IconActivated, String IconDesactivated) {
		super();
		this.IconActivated = IconActivated;
		this.IconDesactivated = IconDesactivated;
		this.isActivate = false;
		this.setIcon(new ImageIcon(getClass().getResource(IconDesactivated)));
		this.setEnabled(false);
	}

	public ButtonFF() {
		super();
		this.isActivate = false;
	}

	public boolean isActivate() {
		return isActivate;
	}

	public void reinit() {
		this.isActivate = false;
		this.setIcon(new ImageIcon(getClass().getResource(IconDesactivated)));
	}

	public void change() {
		this.isActivate = !isActivate;
		if (this.isActivate)
			this.setIcon(new ImageIcon(getClass().getResource(IconActivated)));
		else
			this.setIcon(new ImageIcon(getClass().getResource(IconDesactivated)));
	}

	public void notifyCarte(CTerrain c) {
		if (c.isCarteChargee()){
			this.setEnabled(true);
			reinit();
		}
	}
	
	public void notifySimu(CSimulateur simu) {
		if (simu.isRunning()){
			this.setEnabled(false);
			reinit();
		}
		else {
			this.setEnabled(true);
		}
	}

}


